import React, { useState, memo, useCallback, useMemo } from "react";
// 父组件方法执行不影响子组件
const Child = memo((props) => {
  console.log(123);
  return <button onClick={() => props.doSth()}>累加</button>;
});
export default function App6() {
  const [num, setNum] = useState(1);
//   const doSth = useCallback(() => {
//     setNum(num => num + 1)
// }, []);
  const doSth = useMemo(() => {
  return ()=>setNum(num => num + 1)
}, []);
  return (
    <div>
      <h3>数字为：{num}</h3>
      <hr />
      <Child doSth={doSth} />
    </div>
  );
}
